﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sealight.Core.Domain
{
   public class ProductVariantEntity:BaseEntity
    {
        /// <summary>
        /// Gets or sets the product variant identifier
        /// </summary>
        public virtual Guid ProductVariantID { get; set; }
        /// <summary>
        /// Gets or sets the name
        /// </summary>
        public virtual string Name { get; set; }

        /// <summary>
        /// Gets or sets the SKU
        /// </summary>
        public virtual string SKU { get; set; }

        /// <summary>
        /// Gets or sets the description
        /// </summary>
        public virtual string Description { get; set; }
        /// <summary>
        /// Gets or sets the stock quantity
        /// </summary>
        public virtual int StockQuantity { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to display stock availability
        /// </summary>
        public virtual bool DisplayStockAvailability { get; set; }

        /// <summary>
        /// Gets or sets the minimum stock quantity
        /// </summary>
        public virtual int MinStockQuantity { get; set; }

        /// <summary>
        /// Gets or sets the low stock activity identifier
        /// </summary>
        public virtual int LowStockActivityID { get; set; }
        /// <summary>
        /// Gets or sets the order minimum quantity
        /// </summary>
        public virtual int OrderMinimumQuantity { get; set; }

        /// <summary>
        /// Gets or sets the order maximum quantity
        /// </summary>
        public virtual int OrderMaximumQuantity { get; set; }
        /// <summary>
        /// Gets or sets a value indicating whether to disable buy button
        /// </summary>
        public virtual bool DisableBuyButton { get; set; }

        /// <summary>
        /// Gets or sets the price
        /// </summary>
        public virtual decimal Price { get; set; }

        /// <summary>
        /// Gets or sets the old price
        /// </summary>
        public virtual decimal OldPrice { get; set; }

        /// <summary>
        /// Gets or sets the product cost
        /// </summary>
        public virtual decimal ProductCost { get; set; }

        /// <summary>
        /// Gets or sets the weight
        /// </summary>
        public virtual decimal Weight { get; set; }

        /// <summary>
        /// Gets or sets the length
        /// </summary>
        public virtual decimal Length { get; set; }

        /// <summary>
        /// Gets or sets the width
        /// </summary>
        public virtual decimal Width { get; set; }

        /// <summary>
        /// Gets or sets the height
        /// </summary>
        public virtual decimal Height { get; set; }
        
        /// <summary>
        /// Gets or sets the available start date and time
        /// </summary>
        public virtual DateTime? AvailableStartDateTime { get; set; }

        /// <summary>
        /// Gets or sets the shipped end date and time
        /// </summary>
        public virtual DateTime? AvailableEndDateTime { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the entity is published
        /// </summary>
        public virtual bool Published { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the entity has been deleted
        /// </summary>
        public virtual bool Deleted { get; set; }

        /// <summary>
        /// Gets or sets the display order
        /// </summary>
        public virtual int DisplayOrder { get; set; }

        /// <summary>
        /// Gets or sets the date and time of instance creation
        /// </summary>
        public virtual DateTime CreatedDate { get; set; }

        /// <summary>
        /// Gets or sets the date and time of instance update
        /// </summary>
        public virtual DateTime ModifiedDate { get; set; }
        /// <summary>
        /// Gets or sets the picture identifier
        /// </summary>
        public virtual PictureEntity Picture { get; set; }
        /// <summary>
        /// Gets or sets the product identifier
        /// </summary>
        public virtual ProductEntity Product { get; set; }

        public virtual IList<ProductVariantAttributeEntity> Attributes { get; set; }

        public virtual Sealight.Core.DataAdapter.product_variant ToDataAdapter()
        {            
            return new DataAdapter.product_variant {id= this.ProductVariantID, name=this.Name, available_end_date_time = this.AvailableEndDateTime, available_start_date_time=this.AvailableStartDateTime,
            created_date = this.CreatedDate, deleted = this.Deleted, description = this.Description, disable_buy_button=this.DisableBuyButton, display_order = this.DisplayOrder, display_stock_availability = this.DisplayStockAvailability,
            height = this.Height, length=this.Length, low_stock_activity_id = this.LowStockActivityID, min_stock_quantity=this.MinStockQuantity, 
            modified_date = this.ModifiedDate, old_price = this.OldPrice, order_maximum_quantity=this.OrderMaximumQuantity, order_minimum_quantity=this.OrderMinimumQuantity,
            price = this.Price, product_cost=this.ProductCost, published = this.Published, SKU=this.SKU, stock_quantity = this.StockQuantity, weight=this.Weight, width = this.Width,
                                                    picture = this.Picture != null ? this.Picture.ToDataAdapter() : null,
                                                    product_id = this.Product != null ? this.Product.ProductID : Guid.Empty
            };
        }
    }
}
